'use strict';

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const { router, controller, middleware } = app;
  const { sign, auth, rbac } = middleware;

  // 是否开启API签名验证
  const enableRSAChecker = false;

  // 注意中间件的执行顺序
  const checks = enableRSAChecker ? [sign(), auth(), rbac()] : [auth()];

  // 上传
  router.post('/api/upload/file', controller.upload.file);
  router.post('/api/download/all', controller.download.downloadFiles);

  // 登录
  if (enableRSAChecker) {
    router.post('/api/member/login', sign(), controller.member.login);
  } else {
    router.post('/api/member/login', controller.member.login);
  }
  // active
  router.get('/api/active/list', controller.active.allList);
  router.resources('active', '/api/active', controller.active);
  router.get('/api/member/level', controller.member.allList);
};
